import {hrAjax as proFetch} from 'src/hrpub/common/utils/utils';
import {toast} from 'nc-lightapp-front'
import updateSubButtonStatus from "./updateSubButtonStatus";

export default function saveLine(isSynWork, isdisablepsn) {
    const {areaCode} = this.state;
    const {selectedPsn, orgVal, pageid, editTable, disabledAllArea, getMainTableData} = this.props;
    const changedRows = editTable.getChangedRows(areaCode);
    if (!changedRows) return;
    let postData = {
        areaCode,
        editType: this.editType,
        pk_org: orgVal.refpk,
        pk_psnjob: selectedPsn,
        isSynWork,
        isdisablepsn,
        curRow: {areacode: areaCode, rows: changedRows},
    };
    //const callback = () => {
        proFetch({
            url: '/nccloud/hrtrn/pub/RecordsSaveDoAction.do',
            body: postData,
        })
            .then((res) => {
                if (res.success) {
                    toast({color: "success", content: this.props.json['hi6007-000000']});
                    editTable.setStatus(areaCode, 'browse');
                    this.showAction();
                    disabledAllArea(false);
                    updateSubButtonStatus.call(this, false);
                    this.props.button.setButtonDisabled({
                        'delete': false,
                        'edit': false,
                        'change': false
                    })
                    // this.getSubTableData(selectedPsn);
                    getMainTableData(true);
                }
            });
   // };

    /*const cardData = {
        pageid,
        gridModel: {
            areacode: areaCode,
            pageinfo: {},
            rows: changedRows
        }
    };
    this.props.validateToSave(cardData, callback, {[areaCode]: 'editTable'}, 'grid');*/
}
